/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class GraphModel {

    private ArrayList<PointModel> pointsArray;
    private String name;
    private Algorithm algorithm;
    private boolean callOption;

    public GraphModel(String name, Algorithm algorithm, boolean callOption) {
        this.pointsArray = new ArrayList<PointModel>();
        this.name = name;
        this.algorithm = algorithm;
        this.callOption = callOption;
        init();
    }

    public void init() {
        for (int i = -50; i < 50; i++) {
            algorithm.setVolatility(algorithm.getVolatility() + algorithm.getVolatility() * (i / 100.0));
            if (callOption) {
                pointsArray.add(new PointModel(algorithm.calculateCallPrice(), algorithm.getVolatility()));
            } else {
                pointsArray.add(new PointModel(algorithm.calculatePutPrice(), algorithm.getVolatility()));
            }
        }
    }

    public ArrayList<PointModel> getPointsArray() {
        return pointsArray;
    }

    public void setPointsArray(ArrayList<PointModel> pointsArray) {
        this.pointsArray = pointsArray;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Algorithm getAlgorithm() {
        return algorithm;
    }

    public void setAlgorithm(Algorithm algorithm) {
        this.algorithm = algorithm;
    }

    public boolean isCallOption() {
        return callOption;
    }

    public void setCallOption(boolean callOption) {
        this.callOption = callOption;
    }

}
